<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>父页面</title>
    <script type="text/javascript" src="message.js"></script>
</head>
<body>

    <h1>父页面</h1>
    <iframe src="child.html" width="800px" height="600px"></iframe>
</body>
<script type="text/javascript">
    receiveMessage("msg", function (data, event) {
        console.log(data);
    });
    receiveMessage("color", function (data, event) {
        document.getElementsByTagName("h1")[0].style.color = data;
        console.log(data);
    });

</script>
</html>